package com.train.webadmin.app.model;

import com.baomidou.mybatisplus.annotation.*;
import com.train.common.core.annotation.*;
import lombok.Data;

import java.util.Date;
import java.util.Map;

/**
 * 考试记录实体对象。
 *
 * @author xulei
 * @date 2025-03-07
 */
@Data
@TableName(value = "t_history_paper")
public class THistoryPaper {

    /**
     * id。
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 试卷id。
     */
    @TableField(value = "paper_id")
    private Long paperId;

    /**
     * 学生id。
     */
    @TableField(value = "student_id")
    private Long studentId;

    /**
     * 老师id。
     */
    @TableField(value = "teacher_id")
    private Long teacherId;

    /**
     * 耗时s。
     */
    @TableField(value = "time_consuming")
    private Integer timeConsuming;

    /**
     * 得分。
     */
    @TableField(value = "score")
    private Double score;

    /**
     * 交卷时间。
     */
    @TableField(value = "examination_time")
    private Date examinationTime;

    /**
     * 开始时间。
     */
    @TableField(value = "start_time")
    private Date startTime;

    /**
     * 评价。
     */
    @TableField(value = "content")
    private String content;

    /**
     * 创建时间。
     */
    @TableField(value = "create_time")
    private Date createTime;

    /**
     * 修改时间。
     */
    @TableField(value = "update_time")
    private Date updateTime;

    /**
     * 创建人id。
     */
    @TableField(value = "create_user_id")
    private Long createUserId;

    /**
     * 修改人id。
     */
    @TableField(value = "update_user_id")
    private Long updateUserId;

    /**
     * 逻辑删除标记字段(1: 正常 -1: 已删除)。
     */
    @TableLogic
    @TableField(value = "deleted_flag")
    private Integer deletedFlag;

    @RelationOneToOne(
            masterIdField = "paperId",
            slaveModelClass = TPaperInfo.class,
            slaveIdField = "id")
    @TableField(exist = false)
    private TPaperInfo tPaperInfo;

    @RelationOneToOne(
            masterIdField = "studentId",
            slaveModelClass = StudentInfo.class,
            slaveIdField = "id")
    @TableField(exist = false)
    private StudentInfo studentInfo;

    @RelationOneToOne(
            masterIdField = "teacherId",
            slaveModelClass = TeacherInfo.class,
            slaveIdField = "id")
    @TableField(exist = false)
    private TeacherInfo teacherInfo;

    @RelationDict(
            masterIdField = "paperId",
            equalOneToOneRelationField = "tPaperInfo",
            slaveModelClass = TPaperInfo.class,
            slaveIdField = "id",
            slaveNameField = "title")
    @TableField(exist = false)
    private Map<String, Object> paperIdDictMap;

    @RelationDict(
            masterIdField = "studentId",
            equalOneToOneRelationField = "studentInfo",
            slaveModelClass = StudentInfo.class,
            slaveIdField = "id",
            slaveNameField = "name")
    @TableField(exist = false)
    private Map<String, Object> studentIdDictMap;

    @RelationDict(
            masterIdField = "teacherId",
            equalOneToOneRelationField = "teacherInfo",
            slaveModelClass = TeacherInfo.class,
            slaveIdField = "id",
            slaveNameField = "name")
    @TableField(exist = false)
    private Map<String, Object> teacherIdDictMap;
}
